
from flask import Flask, views

app = Flask(__name__)


def te1(func):
    def inner(*args, **kwargs):
        print('before1')
        result = func(*args, **kwargs)
        print('after1')
        return result
    return inner


def te2(func):
    def inner(*args, **kwargs):
        print('before2')
        result = func(*args, **kwargs)
        print('after2')
        return result
    return inner


class UserView(views.MethodView):
    methods = ['GET', 'POST']
    decorators = [te1, te2]

    def get(self):
        print('get')
        return 'get'

    def post(self):
        print('post')
        return 'post'


app.add_url_rule('/user', view_func=UserView.as_view('user'))  # endpoint


if __name__ == '__main__':
    app.run()
